package cn.iocoder.yudao.module.system.controller.admin.mini.other.shopGuide.controller.admin.shopguide;

import cn.hutool.http.HttpUtil;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.module.system.controller.admin.mini.orderInfo.back.controller.admin.back.WxLoginVo;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.shopGuide.controller.admin.shopguide.vo.ShopGuidePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.shopGuide.dal.dataobject.shopguide.ShopGuideDO;
import cn.iocoder.yudao.module.system.controller.admin.mini.other.shopGuide.service.shopguide.ShopGuideService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.*;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;

import java.io.*;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "管理后台 - 导购")
@RestController
@RequestMapping("/qd/shop-guide")
@Validated
public class ShopGuideController {

    @Resource
    private ShopGuideService shopGuideService;

    @PostMapping("/create")
    @Operation(summary = "创建导购")
    @PreAuthorize("@ss.hasPermission('qd:shop-guide:create')")
    public CommonResult<Integer> createShopGuide(@Valid @RequestBody ShopGuideDO createReqVO) throws IOException {
        return success(shopGuideService.createShopGuide(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新导购")
    @PreAuthorize("@ss.hasPermission('qd:shop-guide:update')")
    public CommonResult<Boolean> updateShopGuide(@Valid @RequestBody ShopGuideDO updateReqVO) {
        shopGuideService.updateShopGuide(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除导购")
    @Parameter(name = "id", description = "编号", required = true)
    @PreAuthorize("@ss.hasPermission('qd:shop-guide:delete')")
    public CommonResult<Boolean> deleteShopGuide(@RequestParam("id") Integer id) {
        shopGuideService.deleteShopGuide(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得导购")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('qd:shop-guide:query')")
    public CommonResult getShopGuide(@RequestParam("id") Integer id) {
        return success(shopGuideService.getShopGuide(id));
    }



    @GetMapping("/page")
    @Operation(summary = "获得导购分页")
    @PreAuthorize("@ss.hasPermission('qd:shop-guide:query')")
    public CommonResult getShopGuidePage(@Valid ShopGuidePageReqVO pageVO) {
        return success(shopGuideService.getShopGuidePage(pageVO));
    }




}
